from config import UBT_VERSION
from util import ensure_root, file_backup

import requests


def main():
    # 备份文件
    path = '/etc/apt/sources.list'
    file_backup(path)
    # 生成源
    url_source_gen = f'https://mirrors.ustc.edu.cn/repogen/conf/ubuntu-https-4-{UBT_VERSION}'
    r = requests.get(url_source_gen)
    source = r.text
    f = open(path, 'w')
    f.write(source)
    

if __name__ == "__main__":
    ensure_root()
    main()
